<?php
/* -------------------------------------------------------------------------
 * Nom du fichier : content.php
 * -------------------------------------------------------------------------
 */ 

// Définition du répertoire root
define('SITE_ROOT', '..');

// Définition du fuseau horaire
date_default_timezone_set("Europe/Paris");
    
// Session Start
if(!isset($_SESSION)) session_start();

// Include
include(SITE_ROOT . '/inc/functions_debug.php');
include(SITE_ROOT . '/inc/include.php');
include(SITE_ROOT . '/inc/class_db.php');

// Vérification auth
check_auth();

// Début du html
htmlstart();

// Header
divheader();

//Contenu central
?>
<section id="principal">
		<div id="adminmenu">
			<input type="button" class="miniboutton" id="viewlogs" value="Logs"/>
			<input type="button" class="miniboutton" id="viewusers" value="Utilisateurs"/>
			<input type="button" class="miniboutton" id="viewresult" value="Résulat"/>
		</div>
		<article id="logtable">
			<?
			//Ouvre la connexion à la base de donnée
			$db = New Database;

			$sql = "SELECT * FROM `authlog` ORDER BY `date`  DESC";
			$db->array_query($sql);

			?>
				<table>
                                                <th>Date</th>
                                                <th>Nom</th>
                                                <th>IP</th>
                                                <th>OS</th>
                                                <th>Navigateur</th>
                                                <th>Etat</th>
			<?
			while( $row = $db->retourArray() ) {
		        	$navi = explode(" ", $row['navigateur']);
				?>
					<tr>
						<td><?=$row['date']?></td>
						<td><?=$row['name']?></td>
						<td><?=$row['IP']?></td>
						<td><img src="../pics/<?=$row['os']?>.jpg" alt="" height="20px" /></td>
						<td><img src="../pics/<?=$navi['1']?>.png" alt="" height="20px" /></td>
						<td><img src="../pics/<?=$row['status']?>.png" alt="" height="20px" /></td>
					</tr>
        			<?
			}
			?>
				</table>
		</article>
		<article id="users">
		</article>
		<article id="result">
			<?
			//Ouvre la connexion à la base de donnée
                        $db = New Database;

                        $sql = "SELECT * FROM `users` WHERE `reserved` != 2 ORDER BY `id`  ASC";
                        $db->array_query($sql);
				
			while( $row = $db->retourArray() ) {
				$sql2 = "SELECT * FROM `users` WHERE `id` = '".$row['victim']."'";
				$db->select_query($sql2);
				$vic = $db->retourLigne();
				?>
			    	<p>
					<img src="<?=$row['img']?>" alt="" width="40px" />
					<img src="../pics/fleche_rouge.png" alt="" width="30px" />
					<img src="<?=$vic['img']?>" alt="" width="40px" />
				</p>
				<?
			}
			?>
		</article>
</section>
<?

// Footer
divfooter();

//load javascript
loadajax();

// Fin du html
htmlstop();

// Debug                                                                                                                                                                  
// debug_environnement();

?>

